<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>教室信息编辑</title>
    <link rel="stylesheet" href="${basePath}/plugins/kitadmin/css/theme/default.css" id="theme">
    <link rel="stylesheet" href="${basePath}/plugins/kitadmin/css/kitadmin.css" id="kitadmin">
    <link rel="stylesheet" href="${basePath}/css/doc.css">
    <link rel="stylesheet" href="${basePath}/plugins/kitadmin/css/layui.css" id="layui">
</head>
<body>

<div class="kit-doc">
    <form class="layui-form layui-form-pane" action="">

        <input type="hidden" name="id" value="${classroom.id}">

        <div class="layui-form-item">
            <label class="layui-form-label">楼栋</label>
            <div class="layui-input-block">
                <input type="text" value="${classroom.roomBuilding}" name="roomBuilding" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">门牌号</label>
            <div class="layui-input-block">
                <input type="text" value="${classroom.roomNumber}" name="roomNumber" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <textarea name="roomRemark" placeholder="请输入备注" class="layui-textarea" lay-verify="" autocomplete="off">${classroom.roomRemark}</textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <button class="layui-btn" lay-submit="" lay-filter="update">保存</button>
        </div>
    </form>

</div>
<script src="${basePath}/js/jquery.js"></script>
<script src="${basePath}/plugins/kitadmin/layui.js"></script>
<script>

    layui.use(['laydate', 'form'], function () {
        var form = layui.form;
        //监听提交，发送请求
        form.on('submit(update)', function (data) {
            // 发送 POST 请求
            $.post("update", data.field, function (data) {
                // 状态码=200表示 编辑成功
                if (data.status === 200) {
                    layer.alert(data.message, {offset: 't', icon: 1}, function (index) {
                        layer.close(index);
                        // 先得到当前iframe层的索引
                        var index2 = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index2);
                    });

                }
                // 编辑失败，弹窗提示
                else{
                    layer.alert(data.message, {offset: 't', icon: 2});
                }
            });
            return false;
        });
    });

</script>
</body>
</html>